home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CU Amiga Super CD-ROM 19
/
CU Amiga Magazine's Super CD-ROM 19 (1998)(EMAP Images)(GB)[!][issue 1998-02].iso
/
CUCD
/
Online
/
pprx_WAD
/
WebAnimDesigner1_1.pprx
< prev
next >
Wrap
Text File
|
1997-12-05
|
33KB
|
1,090 lines
/* Personal Paint Amiga Rexx script - Copyright © 1997, Andres Paabo. 'SaveAnimGif.pprx 1.7 script is copyright Cloanto (see bottom portion of this script)*/
/* $VER: WebAnimDesigner.pprx 1.1 */
/** ENG
This script is intended to assist in the creation of animated gifs for web pages.
NOTE this program does not create animated gifs itslf. It only helps design the anim or
animbrush that is used as a source for creating the animated gifs. The animated gifs
have to be created with other programs such as Cloanto's DefineAnimGif.pprx and
SaveAnimGif.pprx. However since this runs on Personal Paint. and for convenience, this
script will call on Personal Paint's 'SaveAnimGif.pprx' (in slightly modified form) and
pass information to it.
*/
IF ARG(1, EXISTS) THEN
PARSE ARG PPPORT
ELSE
PPPORT = 'PPAINT'
IF ~SHOW('P', PPPORT) THEN DO
IF EXISTS('PPaint:PPaint') THEN DO
ADDRESS COMMAND 'Run >NIL: PPaint:PPaint'
DO 30 WHILE ~SHOW('P',PPPORT)
ADDRESS COMMAND 'Wait >NIL: 1 SEC'
END
END
ELSE DO
SAY "Personal Paint could not be loaded."
EXIT 10
END
END
IF ~SHOW('P', PPPORT) THEN DO
SAY 'Personal Paint Rexx port could not be opened'
EXIT 10
END
ADDRESS VALUE PPPORT
OPTIONS RESULTS
OPTIONS FAILAT 10000
/*********ANIM IS SET UP****WHAT TO DO NEXT***************************/
openWAD= getclip('openWAD')
if openWAD = "" then DO
/*******************ENSURES SCREEN NOT TOO SMALL & STUFF IS WITHIN SCREEN*****************/
accept = 0
GET 'SCREENW'
scw = result
if scw >= 640 then DO
GET 'SCREENH'
sch = result
if sch >= 400 then DO
GET 'IMAGEW'
imgw = result
if imgw <= scw then DO
GET 'IMAGEH'
imgh = result
if imgh <= sch then accept = 1
END
END
END
if accept = 0 then DO
Requestnotify 'TITLE "CHANGE SCREEN or IMAGE SIZE" PROMPT "For viewability, screen
size must be 640x 400 or greater, and image size equal or less the screen size"'
EXIT 0
END
/********/
call setclip('openWAD', 1)
END
/********THE ABOVE IS DONE ONLY AT VERY START****IF OPENWAD =""****/
numcolors2=getclip('numcolors2')
GET 'COLORS'
numcolors=result
if numcolors = 256 then DO; RequestResponse 'PROMPT "You must start on the source page.
Proceed if okay. Cancel if not."';if rc~=0 then EXIT 0;END
if numcolors = numcolors2 then DO
switchenvironment
GET 'COLORS'
numcolors=result
end
SETFRAMEPOSITION 1
REQUESTER:
txt_gad_title = 'WEB ANIM DESIGNER 1.1 by A.Paabo for use with Personal Paint 7.+'
txt_gad_transp = 'transparency'
txt_gad_dispose = 'dispose'
txt_gad_optimize = 'Optimization:'
txt_gad_optimnone = '1.None (Constant size & position)'
txt_gad_optimdelta = '3.Deltas (Varying size & position)'
txt_gad_optimbndy= '2.Boundaries (Varying size & position)'
txt_gad_operation = 'SELECT OPERATION:'
txtnew = 'WEBANIMDESIGNER OPERATES ON THE CURRENT ANIMATION'
txt_gad_preview = '1.SIMULATE animgif in 2nd environment'
txt_gad_anbrush = 'Special Animbrush Operations '
txt_gad_anbrushnone = '(When selected, overrides above operations)'
txt_gad_pickup = '2.pick up web anim as annotated animbrush'
txt_gad_animload = '1.make current animbrush into WAD anim'
txt_gad_final = '2.MAKE ANIMGIF via Cloanto SaveAnimGif'
txt_gad_drawrect = 'simulation:show frame rectangles'
txt_gad_curglobal = 'define global rectangle'
txt_gad_curglobal0 = '(use current global rectangle) '
txt_gad_curglobal1 = '1.let WAD determine new from anim'
txt_gad_curglobal2 = '2. User-define new with mouse'
transpcol = getclip('transpcol'); if transpcol = "" then transpcol=0
X0 = getclip('X0')
Y0 = getclip('Y0')
X1 = getclip('X1')
Y1 = getclip('Y1')
GETFRAMES
frames=result
transp=getclip('transp')
if transp = "" then transp = 1
dispose = getclip('dispose')
if dispose = "" then dispose = 1
optimization= getclip('optimization')
if optimization="" then optimization = 0
drawrect= getclip('drawrect')
if drawrect="" then drawrect=1
curglobal = getclip('curglobal')
if curglobal="" then curglobal=0
anbrush=0
operation = getclip('operation')
if operation = "" then operation =0
Request '"'txt_gad_title'" ' ||,
' "TEXT = ""'txtnew'"" '||,
' CHECK = ""'txt_gad_transp'"", 'transp' ' ||,
' CHECK = ""'txt_gad_dispose'"", 'dispose' ' ||,
' CYCLE = ""'txt_gad_optimize'"", 3, 'optimization', ""'txt_gad_optimnone'"",""'txt_gad_optimbndy'"", ""'txt_gad_optimdelta'"" ' ||,
' CYCLE = ""'txt_gad_curglobal'"", 3, 'curglobal', ""'txt_gad_curglobal0'"", ""'txt_gad_curglobal1'"", ""'txt_gad_curglobal2'"" ' ||,
' VSPACE = 8 ' ||,
' CYCLE = ""'txt_gad_operation'"", 2, 'operation',""'txt_gad_preview'"", ""'txt_gad_final'"" '||,
' VSPACE = 8 ' ||,
' CHECK = ""'txt_gad_drawrect'"", 'drawrect' ' ||,
' SEPARATOR ' ||,
' CYCLE = ""'txt_gad_anbrush'"", 3, 'anbrush', ""'txt_gad_anbrushnone'"", ""'txt_gad_animload'"", ""'txt_gad_pickup'"" "'
if rc~=0 then EXIT 0
if rc = 0 then DO
transp = RESULT.1
dispose = RESULT.2
optimization = RESULT.3
curglobal = RESULT.4
operation = RESULT.5
drawrect = RESULT.6
anbrush = RESULT.7
END
call setclip('transp', transp)
call setclip('dispose', dispose)
call setclip('operation', operation)
call setclip('optimization', optimization)
call setclip('drawrect', drawrect)
call setclip('curglobal', curglobal)
call setclip('anbrush', anbrush)
if anbrush = 1 then DO
GetBrushAttributes 'FRAMES'
frames = RESULT
IF frames < 2 then DO
Requestnotify 'PROMPT "You selected animbrush but there is no animbrush present.
We exit."'
EXIT 0
END
if frames ~< 2 then call BRUSHLOADER
END
if anbrush = 2 then DO
Getframes
frames = result
if frames < 2 then DO
Requestnotify 'PROMPT "You selected to pick up an animbrush but there is no animation present"'
EXIT
END
if X0 = "" then DO
Requestnotify 'PROMPT "No global rectangle is defined. We do not know what area to pick up."'
EXIT
END
call PICKUPABRUSH /*does not continue to save as there is an anbrush=2 block*/
END
if transp= 0 then SET '"TRANSP=0"'
if transp=1 then SET '"TRANSP=1"'
Getframes
frames = result
if frames <2 then DO
Requestnotify 'PROMPT "There is no animation to work on. Load an animation, or make
one from animbrush"'
EXIT
END
if curglobal = 0 then DO
if X0 = "" then DO
Requestnotify 'PROMPT "There is no previous global rectangle
definition. You must define the global rectangle. Try again."'
EXIT
END
END
if curglobal = 1 then call GLOBALAREA
if curglobal = 2 then call DEFINERECT
if operation = 1 then CALL PICKUPABRUSH /*saveanimgif bypasses it all*/
if optimization = 1 then DO
if transp =0 then Requestnotify 'PROMPT "Boundaries optimization in settings other
than transp=1 and dispose=1 may produce a webanim result different from the source Amiga
animation."'
END
if optimization = 2 then DO
if transp =1 then Requestnotify 'PROMPT "Deltas optimization in settings other than
transp=0 and dispose=0 may produce a webanim result different from the source Amiga
animation."'
END
SWITCHENVIRONMENT
DELETEFRAMES ALL FORCE
CLEARIMAGE
if numcolors < 256 then numcolors2 = numcolors*2
if numcolors = 256 then numcolors2 = numcolors
Set 'FORCE "COLORS='numcolors2'"'
col = '153 153 153'
col2 = '204 204 204'
Setcolors 'FROM "'numcolors2-1'" COLORS "'col'"'
Setcolors 'FROM "'numcolors2-2'" COLORS "'col2'"'
SETPEN 'BACKGROUND' numcolors2-1
call setclip('numcolors2', numcolors2)
Clearimage
CALL TEXTSRECT
ADDFRAMES
SWITCHENVIRONMENT
/*********BEGIN***********/
SETFRAMEPOSITION 1
/*************************/
if optimization=0 then DO
DO frm = 1 to frames
SETFRAMEPOSITION frm
GETFRAMEDELAY frm
delay = result
Definebrush x0 y0 x1 y1
setbrushhandle UPPERLEFT
SWITCHENVIRONMENT
SETFRAMEPOSITION frm
SETFRAMEDELAY delay
usebrushpalette
remapimage
if dispose = 0 then Putbrush x0 y0
if frm < frames then ADDFRAMES 1 AFTER
if dispose = 1 then Putbrush x0 y0
SWITCHENVIRONMENT
END
END
/*********BOUNDARIES*****************/
if optimization=1 then DO
DO frm = 1 to frames
SETFRAMEPOSITION frm
GETFRAMEDELAY frm
delay = result
GetImageAttributes 'BOUNDARIES'
PARSE VAR RESULT bx0 by0 bx1 by1 rest
if bx0 <= X0 then bx0 = X0
if by0 <= Y0 then by0 = Y0
if bx0 >= X1 then bx0 = X1
if by0 >= Y1 then by0 = Y1
if bx1 >= X1 then bx1 = X1
if by1 >= Y1 then by1 = Y1
if bx1 <= X0 then bx1 = X0
if by1 <= Y0 then by1 = Y0
Definebrush bx0 by0 bx1 by1
setbrushhandle UPPERLEFT
SWITCHENVIRONMENT
SETFRAMEPOSITION frm
SETFRAMEDELAY delay
usebrushpalette
remapimage
if dispose = 0 then Putbrush bx0 by0
if frm < frames then ADDFRAMES 1 AFTER
if dispose = 1 then Putbrush bx0 by0
freebrush force
Setpen 'FOREGROUND' numcolors2-3
if drawrect=1 then Drawrectangle bx0 by0 bx1 by1
SWITCHENVIRONMENT
END
END
/********DELTA******************/
if optimization=2 then DO
tbmap.0 = 0
tbmap.1 = 0
GET 'COLORS'
bcolors = result
/*get bdepth from number of colros*/
DO bdepth = 1 to 8
if bcolors = (2 ** bdepth) THEN
BREAK
END
bwidth = X1-X0
bheight = Y1-Y0
AllocateBitmap bwidth bheight bdepth
tbmap.0 = result
AllocateBitmap bwidth bheight bdepth
tbmap.1 = result
SETFRAMEPOSITION 1
GETFRAMEDELAY 1
delay = result
DefineBrush X0 Y0 X1 Y1
setbrushhandle upperleft
SWITCHENVIRONMENT
if dispose=1 then ADDFRAMES 1 AFTER
usebrushpalette
remapimage
Putbrush X0 Y0
if dispose = 0 then ADDFRAMES 1 AFTER
SETFRAMEDELAY delay
SWITCHENVIRONMENT
DO frm = 1 to frames-1
SETFRAMEPOSITION frm
GetBitmap X0 Y0 X1-1 Y1-1 'BITMAP' tbmap.0
SETFRAMEPOSITION frm+1
GetBitmap X0 Y0 X1-1 Y1-1 'BITMAP' tbmap.1
GetBitmapDelta tbmap.0 tbmap.1
PARSE VAR RESULT delx0 dely0 delx1 dely1
if delx0 < 0 then DO /*means a value of -1 meaning identical*/
delx0 = 0
dely0 = 0
delx1 = 0
dely1 = 0
END
dx0 = X0 + delx0
dy0 = Y0 + dely0
dx1 = X0 + delx1 + 1
dy1 = Y0 + dely1 + 1
if dx0 <= X0 then dbx0 = X0
if dy0 <= Y0 then dy0 = Y0
if dx0 >= X1 then dx0 = X1
if dy0 >= Y1 then dy0 = Y1
if dx1 >= X1 then dx1 = X1
if dy1 >= Y1 then dy1 = Y1
if dx1 <= X0 then dx1 = X0
if dy1 <= Y0 then dy1 = Y0
Definebrush dx0 dy0 dx1 dy1
SwitchENvironment /*to switch env*/
SETFRAMEPOSITION frm+1
GETFRAMEDELAY frm
delay = result
Usebrushpalette
remapimage
SetBrushHandle UPPERLEFT
if dispose = 0 then PutBrush dx0 dy0
if frm <frames-1 then ADDFRAMES 1 AFTER
if dispose = 1 then PutBrush dx0 dy0
FreeBrush FORCE
SETPEN 'FOREGROUND' numcolors2-3
if drawrect=1 then DrawRectangle dx0 dy0 dx1 dy1 /*the delta*/
SETFRAMEDELAY delay
SWITCHENVIRONMENT
END
END
/***********************/
SwITCHENVIRONMENT
SETFRAMEPOSITION 1
PLAY
/***********************************/
/*********************************************/
EXIT
/*****************************************/
GLOBALAREA:
RequestResponse 'TITLE "AUTOMATIC DETERMINATION OF SMALLEST OVERALL AREA" PROMPT
"This process requires the anim is surrounded by a clear, clean, field of background
color. If not, cancel, and use user-define method instead."'
If rc~=0 then EXIT
maxdx = 0
maxdy= 0
mindx = 4000
mindy = 4000
DO frm = 1 to frames
SETFRAMEPOSITION frm
GetImageAttributes 'BOUNDARIES'
PARSE VAR RESULT dx0 dy0 dx1 dy1 rest
if dx0 < mindx then mindx = dx0
if dy0 < mindy then mindy = dy0
if dx1 > maxdx then maxdx = dx1
if dy1 > maxdy then maxdy = dy1
END
X0 = mindx
Y0 = mindy
X1 = maxdx
Y1 = maxdy
call setclip('X0', X0)
call setclip('Y0', Y0)
call setclip('X1', X1)
call setclip('Y1', Y1)
rc=0
RETURN
/***********************************************/
TEXTSRECT:
GET 'IMAGEW'
imgw = RESULT
Xmid = TRUNC(imgw/2)
SETPEN 'FOREGROUND' numcolors2-2
Text 'TEXT "WebAnimDesigner 1.1 by Andres Pääbo (c)97 -- email: paabo@bancom.net" "fonts:" "times" "10" "of" "'Xmid'" "20" CENTER'
Text 'TEXT "SIMULATION OF ANIM GIF ON WEB PAGE" "fonts:" "times" "20" "of" "'Xmid'" "40" CENTER'
Text 'TEXT "(IF ACTIVE)LARGE RECTANGLE SHOWS GLOBAL ANIMGIF SIZE.SMALLER RECTANGLES SHOW FRAME SIZES" "fonts:" "times" "10" "of" "'Xmid'" "60" CENTER'
if transp=1 then DO
if dispose = 1 then Text 'TEXT "angif setting at TRANSPARENCY=1 DISPOSE=1" "fonts:" "times" "15" "of" "'Xmid'" "70" CENTER'
if dispose = 0 then Text 'TEXT "angif setting at TRANSPARENCY=1 DISPOSE=0" "fonts:" "times" "15" "of" "'Xmid'" "70" CENTER'
END
if transp=0 then DO
if dispose = 1 then Text 'TEXT "angif setting at TRANSPARENCY=0 DISPOSE=1" "fonts:" "times" "15" "of" "'Xmid'" "70" CENTER'
if dispose = 0 then Text 'TEXT "angif setting at TRANSPARENCY=0 DISPOSE=0" "fonts:" "times" "15" "of" "'Xmid'" "70" CENTER'
eND
if optimization = 0 then Text 'TEXT "OPTIMIZATION=NONE (CONST FRAME & POSTITION)" "fonts:" "times" "15" "of" "'Xmid'" "85" CENTER'
if optimization =1 then Text 'TEXT "OPTIMIZATION=BOUNDARIES" "fonts:" "times" "15" "of" "'Xmid'" "85" CENTER'
if optimization = 2 then Text 'TEXT "OPTIMIZATION=DELTA" "fonts:" "times" "15" "of" "'Xmid'" "85" CENTER'
freebrush FORCE
if drawrect=1 then DrawRectangle X0 Y0 X1 Y1
RETURN
/*********************************************/
/*************************************************/
BRUSHLOADER:
/**if frames ~< 2 then continue as originally***/
CLEARIMAGE
FREEENVIRONMENT FORCE
SWITCHENVIRONMENT
GetbrushAttributes 'COLORS'
numcolors = RESULT
Set 'FORCE "COLORS='numcolors'"'
copyenvironment FORCE
Set 'FORCE "TRANSP= 1"'
GET 'IMAGEW'
imgw = RESULT
GET 'IMAGEH'
imgh = RESULT
imgmid = TRUNC(imgw/2)
GetBrushAttributes 'FRAMES'
frames = RESULT
GetBrushAttributes WIDTH
width = result
if width > imgw-100 then DO; Requestnotify 'TITLE "ANIMBRUSH TO WIDE" PROMPT "The animbrush is too
wide. Use larger screen size"';EXIT 0; END
GetBrushAttributes HEIGHT
height = RESULT
if height > imgh-100 then DO; Requestnotify 'TITLE "ANIMBRUSH TO WIDE" PROMPT "The animbrush is too
high. Use larger screen size."'; EXIT 0; END
x0 = TRUNC((imgw-width)/2)
y0 = TRUNC((imgh-height)/2)
x1 = x0 + width
y1 = y0 + height
setbrushhandle UPPERLEFT
UseBrushPalette
GetBrushAttributes 'TRANSPARENCY'
transp = RESULT
IF transp=0 then transpcol = 0
If transp >0 then DO
GetBrushAttributes 'TRANSPARENTCOLOR'
transpcol = RESULT
setpen 'BACKGROUND' transpcol
END
/************CLEAR TO ABRS TRANSP COLOR & STAMP DOWN*************************/
GetBrushInfo 'ANNOTATION'
frame_annot = RESULT
delayannot = 0
loop = -1
delay. = 0
IF WORD(frame_annot, 1) = 'LOOP' & WORD(frame_annot, 3) = 'DELAY' THEN DO
delayannot=1
loop = WORD(frame_annot, 2)
IF ~DATATYPE(loop, 'W') THEN
loop = -1
DO frm = 1 TO frames
del = WORD(frame_annot, 3+frm)
IF DATATYPE(del, 'W') THEN
delay.frm = del
delay.frm = TRUNC(delay.frm*(60/100))
END
END
SETPEN 'BACKGROUND' transpcol
ClearImage
ADDFRAMES frames AFTER
DO frm = 1 TO frames
SETFRAMEPOSITION frm
if delayannot=1 then SETFRAMEDELAY delay.frm
if delayannot = 0 then SETFRAMEDELAY 10
SetBrushAttributes 'FRAMEPOSITION' frm
Usebrushpalette
Putbrush X0 y0
END
SETFRAMEPOSITION 1
call setclip('X0', X0)
call setclip('Y0', Y0)
call setclip('X1', X1)
call setclip('Y1', Y1)
call setclip('openWAD', 1)
call setclip('operation', 1)
call setclip('curglobal', 0 )
freebrush /*not needed as we make the preview version from the image*/
PLAY 3
Requestnotify 'PROMPT " An anim has been established from the animbrush on the center of the page,
making the original animbrush area as the initial global rectangle. Reenter W.A.D. and continue."'
EXIT 0
/******************create pickup rectangle**********************/
DEFINERECT:
Requestnotify 'PROMPT "Define the overall (global) rectangle with mouse"'
SetCurrentBrush 'RECTANGULAR WIDTH 1 HEIGHT 1'
GetPen 'FOREGROUND'
savepen = RESULT
Get 'COLORS'
SetPen 'FOREGROUND' RESULT-1
DisableTools
WaitForClick 'DOWN POINT SHOWBRUSH'
IF RC = 0 THEN DO
PARSE VAR RESULT button x0 y0 .
prev_x1 = x0
prev_y1 = y0
drawn = 0
DO FOREVER
GetMousePosition
PARSE VAR RESULT x1 y1 .
IF x1 ~= prev_x1 | y1 ~= prev_y1 | ~drawn THEN DO
If drawn THEN
Undo
DrawRectangle x0 y0 x1 y1 'COMPLEMENT'
prev_x1 = x1
prev_y1 = y1
drawn = 1
END
ELSE WaitForEvent
GetMouseButton
IF RESULT ~= button THEN
LEAVE
END
IF x0 > x1 THEN DO
t = x0
x0 = x1
x1 = t
END
IF y0 > y1 THEN DO
t = y0
y0 = y1
y1 = t
END
call setclip('X0', X0)
call setclip('Y0', Y0)
call setclip('X1', X1)
call setclip('Y1', Y1)
Undo
RETURN
/****************************************************/
PICKUPABRUSH:
GETFRAMES
frames = result
Setframeposition 1
posit = 1
X0 = GETCLIP('X0')
Y0 = GETCLIP('Y0')
X1 = GETCLIP('X1')
Y1 = GETCLIP('Y1')
/********get animation project info if exists****************/
GetProjectInfo 'COPYRIGHT'
annot = RESULT
/***get time delays from source animation, convert to 100ths if asked***/
DO frm = 1 to frames
GetFrameDelay 'FRAME' frm
del = RESULT
delay.frm = TRUNC((del * 100/60) + 0.5)
END
/*******make animbrush********/
DefineBrush X0 Y0 X1 Y1 'FRAMES' frames
/*******annotate animbrush with delay timings********/
loop = 1
frame_annot = 'LOOP' loop 'DELAY'
DO frm = 1 TO frames
frame_annot = frame_annot delay.frm
END
SetBrushInfo 'ANNOTATION "'frame_annot'"'
SetBrushInfo 'COPYRIGHT "'annot'"'
if anbrush = 2 then DO
Requestnotify 'PROMPT "an annotated animbrush has been picked up"'
EXIT
END
/****************continue into other scripts*********************/
/*********NOTE: THESE CALL ON THIRD PARTY SCRIPTS THAT***********/
/**************ACTUALLY CREATE THE ANIMATED GIFS.*****************/
call setclip('dispose', dispose)
call setclip('optimization', optimization)
CALL WADSaveAnimGif
EXIT 0
WADSaveAnimGif:
/**********INFO FROM WEB ANIM DESIGNER***********/
/*****not provided in annotated animbrush********/
/*optimization = getclip('optimization');dispose = getclip('dispose')*/
if optimization = 0 then optimname = 'NONE'
if optimization = 1 then optimname = 'BOUNDARIES'
if optimization = 2 then optimname = 'DELTA'
REQUESTRESPONSE 'TITLE "SETTINGS TO BE USED" PROMPT "optimization='optimname' dispose='dispose' transp='transp'"'
/**************************************************/
/************MODIFIED SaveANimGif.pprx*************************************/
/****not part of this program. Provided for your convenience**********/
/* Personal Paint Amiga Rexx script - Copyright © 1996, 1997 Cloanto Italia srl */
/* $VER: MODIFIED SaveAnimGif.pprx 1.7 */
/*MODIFIED SaveAnimGif.pprx 1.7. The modifications are simple ones to allow the above host program
to pass to it the parameters this program uses. Since the parameteers are passed to it, the
settings requester is not needed, and that portion of the script has been removed. Also, to
permit the creation of various situations other than just delta-nontransp-nodispose and
boundaries-transp-dispose, explicit control of the host's variable 'optimization' is simply
introduced, and more output possibilities than the above two are permitted. All modified sections
are marked*/
/****MODIFICATION****remove entry script since it is already acheived at the top of this overall script***/
/*******MODIFICATION ****as settings requester removed, gadget texts relating to it removed. These
remain. Non English excluded in this version***/
txt_title_req = 'Save GIF Anim-Brush'
txt_err_oldclient = 'This script requires a newer_version of Personal Paint'
txt_err_oldlib = 'This script requires a newer_version of the GIF library'
txt_err_notabsh = 'The current brush_is not an anim-brush'
txt_err_notemp = 'No space for temporary brush'
txt_err_nomem = 'Not enough memory'
txt_err_nosave = 'File I/O error'
Version 'REXX'
IF RESULT < 7 THEN DO
RequestNotify 'PROMPT "'txt_err_oldclient'"'
EXIT 10
END
LockGUI
GetBrushAttributes 'FRAMES'
frames = RESULT
IF frames < 2 THEN DO
RequestNotify 'PROMPT "'txt_err_notabsh'"'
UnlockGUI
EXIT 0
END
GetBrushNumber
bshnum = RESULT
SetCurrentBrush 'UNUSED'
IF RC ~= 0 THEN DO
RequestNotify 'PROMPT "'txt_err_notemp'"'
UnlockGUI
EXIT 0
END
GetBrushNumber
tbshnum = RESULT
SetCurrentBrush 'BRUSH' bshnum
GetBrushInfo 'ANNOTATION'
frame_annot = RESULT
loop = -1
delay. = 0
IF WORD(frame_annot, 1) = 'LOOP' & WORD(frame_annot, 3) = 'DELAY' THEN DO
loop = WORD(frame_annot, 2)
IF ~DATATYPE(loop, 'W') THEN
loop = -1
DO frm = 1 TO frames
del = WORD(frame_annot, 3+frm)
IF DATATYPE(del, 'W') THEN
delay.frm = del
END
END
use_loop = (loop >= 0)
IF loop < 0 THEN
loop = 0
fnlen = LENGTH(frames)
dsel = 1
do_req = 1
deltype = 0
GetBrushInfo 'COPYRIGHT'
annot = RESULT
max_annot_size = LENGTH(annot) * 2
IF max_annot_size < 200 THEN
max_annot_size = 200
GetBrushAttributes 'TRANSPARENCY'
transp = RESULT
IF transp ~= 1 THEN
transp = 0
/*****MODIFICATION*****all matters pertaining to the settings requester have been removed since
the host provides all settings data. We continue at the following lines*****/
IF ~use_loop THEN
loop = -1
frame_annot = 'LOOP' loop 'DELAY'
DO frm = 1 TO frames
frame_annot = frame_annot delay.frm
END
SetBrushInfo 'ANNOTATION "'frame_annot'"'
RequestFile '"'txt_title_req'" SAVEMODE'
IF RC = 0 THEN DO
PARSE VALUE RESULT WITH '"' fname '"'
tempfile = 'T:PP_AnGif.'PRAGMA('ID')
GetBrushAttributes 'FRAMEFIRST'
sv_frmin = RESULT
GetBrushAttributes 'FRAMELAST'
sv_frmax = RESULT
GetBrushAttributes 'LENGTH'
sv_frlen = RESULT
GetBrushAttributes 'FRAMEPOSITION'
sv_frpos = RESULT
Get 'ICONS'
sv_icons = RESULT
GetBrushAttributes 'WIDTH'
bwidth = RESULT
GetBrushAttributes 'HEIGHT'
bheight = RESULT
GetBrushAttributes 'TRANSPARENTCOLOR'
transpcol = RESULT
GetBrushAttributes 'COLORS'
bcolors = RESULT
plt_size = bcolors * 3
Get 'PATHBSH'
PARSE VAR RESULT '"' sv_pathbsh '"'
/*****MODIFICATION****we remove the following lines because they only provide two options
IF transp = 1 THEN
pckinfo = '09'x
ELSE
pckinfo = '00'x ******/
/*******MODIFICATION*****we replace them with these lines which provide a few more*******/
if transp = 0 then DO
if dispose = 0 then pckinfo = '06'x /*notrans nodisp*/
if dispose = 1 then pckinfo = '08'x /*notrans & dispose*/
END
if transp = 1 then DO
if dispose = 0 then pckinfo = '05'x /*trans & nodispose*/
if dispose = 1 then if transp = 1 then pckinfo = '09'x /*trans & dispose*/
END
/************************************/
DO bdepth = 1 TO 8
IF bcolors = (2 ** bdepth) THEN
BREAK
END
tbmap.0 = 0
tbmap.1 = 0
tbnum = 0
gfile_open = 0
global_plt = ''
err_msg = ''
SIGNAL ON Break_C
AllocateBitmap bwidth bheight bdepth
IF RC = 0 THEN DO
tbmap.0 = RESULT
AllocateBitmap bwidth bheight bdepth
IF RC = 0 THEN DO
tbmap.1 = RESULT
SetBrushAttributes 'FRAMEFIRST 1 FRAMELAST' frames 'LENGTH' frames
Set '"ICONS = 0"'
DO frm = 1 TO frames
SetCurrentBrush 'BRUSH' bshnum
IF RC ~= 0 THEN DO
err_msg = txt_err_nomem
BREAK
END
SetBrushAttributes 'FRAMEPOSITION' frm
IF RC ~= 0 THEN DO
err_msg = txt_err_nomem
BREAK
END
GetBitmap '0 0 BITMAP' tbmap.tbnum 'FROMBRUSH'
tbnum = 1 - tbnum
GetBrushColors
local_plt = RESULT
IF frm = 1 THEN DO
dx0 = 0
dy0 = 0
dx1 = bwidth - 1
dy1 = bheight - 1
global_plt = local_plt
END
ELSE DO
/*****MODIFICATION**to make pgm obey host variable= optimization*******/
/*IF transp = 1 THEN*/
if optimization < 2 then GetBrushAttributes 'BOUNDARIES'
ELSE
GetBitmapDelta tbmap.0 tbmap.1
/****MODIFICATION***to force using entire image values if optimization=0**********/
if optimization > 0 then PARSE VAR RESULT dx0 dy0 dx1 dy1 .
/********and that's all!****basically the original program functions as always**************/
IF dx0 < 0 THEN DO
dx0 = 0
dy0 = 0
dx1 = 0
dy1 = 0
END
/********MODIFICATION***remove the IExplorer bug accomodation**which creates problems for
multiple palette animbrushes in nontransp mode*****/
END
SetCurrentBrush 'BRUSH' tbshnum
IF RC ~= 0 THEN DO
err_msg = txt_err_nomem
BREAK
END
CopyBrush bshnum dx0 dy0 dx1 dy1 'NOFRAMES'
IF RC ~= 0 THEN DO
err_msg = txt_err_nomem
BREAK
END
SaveBrush tempfile 'FORCE QUIET NOPROGRESS FORMAT "GIF" OPTIONS "GIF89=1" "PROGDSP=0" "SCRFMT=0"'
IF RC ~= 0 THEN DO
IF RC = 46 | RC = 47 THEN
err_msg = txt_err_oldlib
ELSE
err_msg = txt_err_nosave
BREAK
END
IF ~OPEN('tfile', tempfile, 'R') THEN DO
err_msg = txt_err_nosave
BREAK
END
IF frm = 1 THEN DO
IF ~OPEN('gfile', fname, 'W') THEN DO
err_msg = txt_err_nosave
BREAK
END
gfile_open = 1
data = READCH('tfile', 13) /* sign + screen descriptor */
bxpix = BITOR(BITAND(SUBSTR(data, 11, 1), '07'x), '80'x)
CALL WRITECH('gfile', data)
plt_data = READCH('tfile', plt_size) /* palette */
CALL WRITECH('gfile', plt_data)
do_plt = 0
IF use_loop THEN
CALL WRITECH('gfile', '21FF0B'x || 'NETSCAPE2.0' || '0301'x || IntelWord(loop) || '00'x)
IF annot ~= '' THEN DO /* annotation */
CALL WRITECH('gfile', '21FE'x)
alen = LENGTH(annot)
apos = 1
DO WHILE alen > 0
IF alen <= 255 THEN
aln = alen
ELSE
aln = 255
CALL WRITECH('gfile', D2C(aln) || SUBSTR(annot, apos, aln))
apos = apos + aln
alen = alen - aln
END
CALL WRITECH('gfile', '00'x)
END
END
ELSE DO
CALL SEEK('tfile', 13, 'B')
plt_data = READCH('tfile', plt_size)
do_plt = (global_plt ~== local_plt)
END
DO FOREVER
code = READCH('tfile', 1)
IF code = ',' THEN DO /* image */
/* gfx control */
CALL WRITECH('gfile', '21F904'x || pckinfo || IntelWord(delay.frm) || D2C(transpcol) || '00'x)
data = READCH('tfile', 9) /* Get image descriptor */
imginfo = SUBSTR(data, 9, 1)
IF do_plt THEN
imginfo = BITOR(BITAND(imginfo, '40'x), bxpix)
/* image descriptor */
CALL WRITECH('gfile', ',' || IntelWord(dx0) || IntelWord(dy0) || IntelWord(dx1-dx0+1) || IntelWord(dy1-dy0+1) || imginfo)
IF do_plt THEN
CALL WRITECH('gfile', plt_data)
tpos = SEEK('tfile', 0, 'C')
epos = SEEK('tfile', 0, 'E')
dsize = epos - tpos - 1
CALL SEEK('tfile', tpos, 'B')
/* image data */
DO WHILE dsize > 0
IF dsize > 65000 THEN
tsize = 65000
ELSE
tsize = dsize
data = READCH('tfile', tsize)
CALL WRITECH('gfile', data)
dsize = dsize - tsize
END
BREAK
END
ELSE IF code = '!' THEN DO /* extension */
CALL SEEK('tfile', 1, 'C')
length = 1
DO WHILE length ~= 0
length = C2D(READCH('tfile', 1))
IF length > 0 THEN
CALL SEEK('tfile', length, 'C')
END
END
ELSE BREAK
END
CALL CLOSE('tfile')
END
CALL WRITECH('gfile', ';')
CALL CLOSE('gfile')
gfile_open = 0
ADDRESS COMMAND 'Delete >NIL: 'tempfile
SetCurrentBrush 'BRUSH' tbshnum
IF RC = 0 THEN
FreeBrush 'FORCE'
SetCurrentBrush 'BRUSH' bshnum
IF RC = 0 THEN
SetBrushAttributes 'FRAMEFIRST' sv_frmin 'FRAMELAST' sv_frmax 'LENGTH' sv_frlen 'FRAMEPOSITION' sv_frpos
Set '"ICONS =' sv_icons '"'
FreeBitmap tbmap.1
END
ELSE err_msg = txt_err_nomem
FreeBitmap tbmap.0
END
ELSE err_msg = txt_err_nomem
IF err_msg ~= '' THEN
RequestNotify 'PROMPT "'err_msg'"'
Set '"PATHBSH=""'sv_pathbsh'"" "'
END
UnlockGUI
EXIT 0
IntelWord: PROCEDURE
value = ARG(1)
hibyte = value % 256
lobyte = value - (hibyte * 256)
RETURN D2C(lobyte) || D2C(hibyte)
Break_C:
IF gfile_open THEN
CALL CLOSE('gfile')
ADDRESS COMMAND 'Delete >NIL: 'tempfile
SetCurrentBrush 'BRUSH' tbshnum
IF RC = 0 THEN
FreeBrush 'FORCE'
SetCurrentBrush 'BRUSH' bshnum
IF RC = 0 THEN
SetBrushAttributes 'FRAMEFIRST' sv_frmin 'FRAMELAST' sv_frmax 'LENGTH' sv_frlen 'FRAMEPOSITION' sv_frpos
Set '"ICONS =' sv_icons '"'
IF tbmap.1 ~= 0 THEN
FreeBitmap tbmap.1
IF tbmap.0 ~= 0 THEN
FreeBitmap tbmap.0
Set '"PATHBSH=""'sv_pathbsh'"" "'
RETURN